;*******************************************************************************
; file       : startup_928.s
; description: P928 Device Startup File 
; author     : zhouyao
; data       : 04/02/2013
; (C) COPYRIGHT 2013 Shanghai Haier IC Co., Ltd.
;*******************************************************************************


; <h> Stack Configuration
;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Stack_Size      EQU     0x00000400

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp


; <h> Heap Configuration
;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Heap_Size       EQU     0x00000000

                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit


                PRESERVE8
                THUMB


; Vector Table Mapped to Address 0 at Reset

                AREA    RESET, DATA, READONLY
                EXPORT  __Vectors

__Vectors       DCD     __initial_sp                 ; Top of Stack
                DCD     Reset_Handler             ; Reset IRQIRQHandler
                DCD     NMI_IRQHandler               ; NMI IRQIRQHandler
                DCD     HardFault_IRQHandler         ; Hard Fault IRQIRQHandler
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     SVC_IRQHandler               ; SVCall IRQIRQHandler
                DCD     0                            ; Reserved
                DCD     0                            ; Reserved
                DCD     PendSV_IRQHandler            ; PendSV IRQIRQHandler
                DCD     SysTick_IRQHandler           ; SysTick IRQIRQHandler

                ; External Interrupts
                DCD     PINT0_IRQHandler                   ;16, pint0 IRQIRQHandler
                DCD     PINT1_IRQHandler                   ;17, pint1 IRQIRQHandler
                DCD     PINT2_IRQHandler                   ;18, pint2 IRQIRQHandler
                DCD     PINT3_IRQHandler                   ;19, pint3 IRQIRQHandler
                DCD     PINT4_IRQHandler                   ;20, pint4 IRQIRQHandler
                DCD     PINT5_IRQHandler                   ;21, pint5 IRQIRQHandler
                DCD     PINT6_IRQHandler                   ;22, pint6 IRQIRQHandler
                DCD     PINT7_IRQHandler                   ;23, pint7 IRQIRQHandler
                DCD     T16N0_IRQHandler                   ;24, t16n0 IRQIRQHandler
                DCD     T16N1_IRQHandler                   ;25, t16n1 IRQIRQHandler
                DCD     T16N2_IRQHandler                   ;26, t16n2 IRQIRQHandler
                DCD     T16N3_IRQHandler                   ;27, t16n3 IRQIRQHandler
                DCD     T32N0_IRQHandler                   ;28, t32n0 IRQIRQHandler
                DCD     T32N1_IRQHandler                   ;29, t32n1 IRQIRQHandler
                DCD     0                                  ;30, Reserved
                DCD     0                                  ;31, Reserved
                DCD     TWDT_IRQHandler                    ;32, wdt IRQIRQHandler
                DCD     RTC_IRQHandler                     ;33, rtc IRQIRQHandler
                DCD     0                                  ;34, Reserved
                DCD     ADC_IRQHandler                     ;35, adc  IRQIRQHandler
                DCD     LCD_IRQHandler                     ;36, lcd  IRQIRQHandler
                DCD     LVD_IRQHandler                     ;37, lvd0 IRQIRQHandler
                DCD     0	                			   ;38, Reserved
                DCD     UART0_IRQHandler                   ;39, uart0 IRQIRQHandler
                DCD     UART1_IRQHandler                   ;40, uart1 IRQIRQHandler
                DCD     UART2_IRQHandler                   ;41, uart2 IRQIRQHandler
                DCD     UART3_IRQHandler                   ;42, uart3 IRQIRQHandler
                DCD     EUART0_IRQHandler                  ;43, euart0 IRQIRQHandler 
                DCD     EUART1_IRQHandler                  ;44, euart1 IRQIRQHandler
                DCD     SPI_IRQHandler                     ;45  spi0 IRQIRQHandler
                DCD     IIC0_IRQHandler                    ;46, IIC0 IRQIRQHandler
                DCD     IIC1_IRQHandler                    ;47, IIC1 IRQIRQHandler



;                IF      :LNOT::DEF:NO_CRP
;                AREA    |.ARM.__at_0x02FC|, CODE, READONLY
;CRP_Key         DCD     0xFFFFFFFF
;                ENDIF


                AREA    |.text|, CODE, READONLY


; Reset IRQIRQHandler

Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
			    IMPORT  __main
                LDR     R0, =__main
				BX      R0
				ENDP

; Dummy Exception IRQHandlers (infinite loops which can be modified)                

NMI_IRQHandler     PROC
                EXPORT  NMI_IRQHandler               [WEAK]
                B       .
                ENDP
HardFault_IRQHandler\
                PROC
                EXPORT  HardFault_IRQHandler         [WEAK]
                B       .
                ENDP
SVC_IRQHandler     PROC
                EXPORT  SVC_IRQHandler               [WEAK]
                B       .
                ENDP
PendSV_IRQHandler  PROC
                EXPORT  PendSV_IRQHandler            [WEAK]
                B       .
                ENDP
SysTick_IRQHandler PROC
                EXPORT  SysTick_IRQHandler           [WEAK]
                B       .
                ENDP

Default_IRQHandler PROC



                EXPORT  PINT0_IRQHandler    [WEAK]
                EXPORT  PINT1_IRQHandler    [WEAK]
                EXPORT  PINT2_IRQHandler    [WEAK]
                EXPORT  PINT3_IRQHandler    [WEAK]
                EXPORT  PINT4_IRQHandler    [WEAK]
                EXPORT  PINT5_IRQHandler    [WEAK]
                EXPORT  PINT6_IRQHandler    [WEAK]
                EXPORT  PINT7_IRQHandler    [WEAK]
                EXPORT  T16N0_IRQHandler    [WEAK]
                EXPORT  T16N1_IRQHandler    [WEAK]
                EXPORT  T16N2_IRQHandler    [WEAK]
                EXPORT  T16N3_IRQHandler    [WEAK]
                EXPORT  T32N0_IRQHandler    [WEAK]
                EXPORT  T32N1_IRQHandler    [WEAK]
                EXPORT  TWDT_IRQHandler     [WEAK]
                EXPORT  RTC_IRQHandler      [WEAK]
                EXPORT  ADC_IRQHandler      [WEAK]
                EXPORT  LCD_IRQHandler      [WEAK]
                EXPORT  LVD_IRQHandler      [WEAK]
                EXPORT  UART0_IRQHandler    [WEAK]
                EXPORT  UART1_IRQHandler    [WEAK]
                EXPORT  UART2_IRQHandler    [WEAK]
                EXPORT  UART3_IRQHandler    [WEAK]
                EXPORT  EUART0_IRQHandler   [WEAK]
                EXPORT  EUART1_IRQHandler   [WEAK]
                EXPORT  SPI_IRQHandler      [WEAK]
                EXPORT  IIC0_IRQHandler     [WEAK]
                EXPORT  IIC1_IRQHandler     [WEAK]




PINT0_IRQHandler
PINT1_IRQHandler
PINT2_IRQHandler
PINT3_IRQHandler
PINT4_IRQHandler
PINT5_IRQHandler
PINT6_IRQHandler
PINT7_IRQHandler
T16N0_IRQHandler
T16N1_IRQHandler
T16N2_IRQHandler
T16N3_IRQHandler
T32N0_IRQHandler
T32N1_IRQHandler
TWDT_IRQHandler
RTC_IRQHandler
ADC_IRQHandler
LCD_IRQHandler
LVD_IRQHandler
UART0_IRQHandler
UART1_IRQHandler
UART2_IRQHandler
UART3_IRQHandler
EUART0_IRQHandler
EUART1_IRQHandler
SPI_IRQHandler
IIC0_IRQHandler
IIC1_IRQHandler


                B       .

                ENDP


                ALIGN


; User Initial Stack & Heap

                IF      :DEF:__MICROLIB
                
                EXPORT  __initial_sp
                EXPORT  __heap_base
                EXPORT  __heap_limit
                
                ELSE
                
                IMPORT  __use_two_region_memory
                EXPORT  __user_initial_stackheap
__user_initial_stackheap

                LDR     R0, =  Heap_Mem
                LDR     R1, =(Stack_Mem + Stack_Size)
                LDR     R2, = (Heap_Mem +  Heap_Size)
                LDR     R3, = Stack_Mem
                BX      LR

                ALIGN

                ENDIF

                END

